import hashlib
import base64


def md5_bytes():
    s = 'shuoGG1239'
    h = hashlib.md5()
    h.update(s.encode())
    bs = h.digest()  # bytes
    print(bs)


def md5_string():
    s = 'shuoGG1239'
    h = hashlib.md5()
    h.update(s.encode())
    s_md = h.hexdigest()  # str
    print(s_md)


def sha1_bytes():
    s = 'shuoGG1239'
    h = hashlib.sha1()
    h.update(s.encode())
    bs = h.digest()  # bytes
    print(bs)


def sha1_string():
    s = 'shuoGG1239'
    h = hashlib.sha1()
    h.update(s.encode())
    s_sha1 = h.hexdigest()  # str
    print(s_sha1)


def base64_encode():
    s = 'shuoGG1239'
    bs = base64.urlsafe_b64encode(s.encode())  # bytes
    s_64 = bs.decode()
    print(s_64)
    return s_64


def base_decode():
    be = base64_encode()
    db = base64.urlsafe_b64decode(be)  # bytes
    ds = db.decode()  # str
    print(ds)


md5_bytes()
md5_string()
sha1_bytes()
sha1_string()
base64_encode()
base_decode()
